#ifndef FILEHELPER_H_
#define FILEHELPER_H_
#include "../Entity/Collection.h"
#include "../Entity/Document.h"
using namespace std;
class FileHelper {
public:
	static const int MAX_BUFFER_SIZE = 65536;
	static const int MAX_SIZE_PER_LINE_READ = 1024;
	string outputBuffer;
	char inputBuffer[MAX_SIZE_PER_LINE_READ];
	FileHelper();
	virtual ~FileHelper();
	bool makeDir(string path);
	void writeDict(string basedir);
	void writeFileDict(string path);
	string readBuffer(fstream& in);
	void writeBuffer(string token, ofstream& out, string delimiter);
	void writeTokenDict(string path);
	void importStopwords();
	void DLtcDict(string line, string& termID, string& termCount);
	void writeTermDict(string path);
	void writeTermCountDict(string path);
	void writeAuthorDict(string path);
	void writeAuthorDict_2(string path);
	void writeCategoryDict(string path);
	void writeLinkRepository(string path);
	//void writeTermFwdIndex(string path);
	void writeFwdIndex(string path);
	void writeSemwiki(string path);
	void clearMemory();
	string makeLine(string token, string div, string count);
	string makeLine(string s1, string s2, string s3, string div);
	void divideLine(string line, string& token, string& count);
	void divideLine(string line, size_t& docId, string& path, size_t& barrel_no, size_t&offset);
	void divideLine(string line, string& s1, string& s2, string& s3);
	void flushBuffer(ofstream& out);
};

#endif /* FILEHELPER_H_ */
